<?php

namespace app\company\controller;

use app\company\validate\DeliverDriverWithdrawValidate;
use app\service\traits\Crud;
use app\company\model\DeliverDriverWithdraw as DeliverDriverWithdrawModel;

class DeliverDriverWithdraw extends Base
{
    private DeliverDriverWithdrawModel $model;

    use Crud;

    public function initialize()
    {
        parent::initialize();
        $this->model         = new DeliverDriverWithdrawModel();
        $this->validateClass = DeliverDriverWithdrawValidate::class;
        $this->withSearch    = 'id,no,status,deliver_driver_id';
        $this->isGs          = true;
        $this->append        = 'driver_withdraw_status_text';
    }

    public function format($list)
    {
        return $list->each(function ($item) {
            $item->driver_name = $item->deliverDriver()->value('name');
            $item->audit_time  = setDates($item->audit_time);
        });
    }
}